<?php

namespace haibao\cms\data\starpk;

use \haibao\cms\model\filter\starpk\StarPkProduct as StarPkProductFilter;

class StarPkProduct extends \haibao\cms\data\BaseMysql{

    public function __construct(){
        parent::__construct('\haibao\cms\model\data\starpk\StarPkProduct');
    }
  
    public function addProducInfo($model){
        try{
            $this->add($model);
        } catch( \Exception $e){
            throw $e;
        }
    }
    
    public function getStarPkProductById($celebrityId){
        $starPkProductFilter = new StarPkProductFilter();
        $starPkProductFilter->select(array(
            StarPkProductFilter::CONDITION_FIELD_NAME_ID,
            StarPkProductFilter::CONDITION_FIELD_NAME_STAR_PK_ID,
            StarPkProductFilter::CONDITION_FIELD_NAME_PIC_URL,
            StarPkProductFilter::CONDITION_FIELD_NAME_BRAND_NAME,
            StarPkProductFilter::CONDITION_FIELD_NAME_PRODUCT_NAME,
            StarPkProductFilter::CONDITION_FIELD_NAME_PRODUCT_PRICE,
            StarPkProductFilter::CONDITION_FIELD_NAME_PRODUCT_ID,
            StarPkProductFilter::CONDITION_FIELD_NAME_SALE_URL,
            StarPkProductFilter::CONDITION_FIELD_NAME_SORT_NUM,
            StarPkProductFilter::CONDITION_FIELD_NAME_CREATE_TIME,
        ));
        $starPkProductFilter->order(StarPkProductFilter::CONDITION_FIELD_NAME_SORT_NUM,true);
        $starPkProductFilter->where(StarPkProductFilter::CONDITION_FIELD_NAME_STAR_PK_ID,\haibao\frame\data\query\Condition::CONDITION_EQUAL,(int)$celebrityId);
        return $this->getAll($starPkProductFilter);
    }
    
    public function delStarPkProductById($Id){
        
        try{
        
            $this->removeById($Id);
        
        } catch( \Exception $e){
        
            throw $e;
        }
        
    }
    
    
}